package RPC

import (
	"AttackTracer/RpcMessage/AttackTracer/RpcMessage"
	pb "AttackTracer/RpcMessage/AttackTracer/RpcMessage"
	"context"
	"log"
)

/*
*	Incidents are used for internal messaging
*	modules of Analyzer can send Incident to RpcClient,
*	RpcClient can then create gRPC requests & send to TracingEngine
 */

type Incident struct {
	Name  string
	Value interface{}
}

func reportIncident(i Incident, c RpcMessage.AnalyzerTracingEngineClient, ctx context.Context) error {
	// TODO: add more incident types
	switch i.Name {
	case "SayHello":
		log.Println("Name", i.Name)
		log.Println("Value", i.Value)
		r, err := c.SayHello(ctx, &pb.HelloRequest{Id: rpcConfig.Id})
		if err != nil {
			log.Println("could not greet: %v", err)
			return err
		}
		log.Println("Reply:", r.GetMessage())
		return nil
	default:
		log.Println("Undefined Report Type")
	}
	return nil
}
